package pl.enigmatic.parser.xml;

import java.util.HashMap;
import java.util.Map;


public interface PropertiesNamesMap {

	public String getPropertyName(String xmlname);

	public class Identity implements PropertiesNamesMap {

		@Override
		public String getPropertyName(final String xmlname) {
			return xmlname;
		}

	}

	public static class Impl implements PropertiesNamesMap {

		private final Map<String, String> map = new HashMap<String, String>();

		public Impl() {
			initialize();
		}

		protected void initialize() {}

		protected void addAliases(final String name, final String... aliases) {
			for (String alias : aliases) {
				map.put(alias, name);
			}
		}

		@Override
		public String getPropertyName(final String xmlname) {
			if (map.containsKey(xmlname)) {
				return map.get(xmlname);
			} else {
				return xmlname;
			}
		}
	}
}
